var Common = {
    dictData: {}
}
Common.queryDictList = function (pid,docId,selectedCode) {
	this.dictData['pid'] = pid;
	//提交信息
    var ajax = new $ax(Feng.ctxPath + "/dict/pidList", function (data) {
    	var selDom = $("#"+docId);
    	selDom.html(''); 
    	selDom.append("<option value=''>请选择</option>");
    	for (var i=0;i<data.length;i++) {
    		var item = data[i];
    	     var optionHtml = "<option value='"+item.value+"' ";
    	     if(item.value==selectedCode){
    	    	 optionHtml+= " selected='selected' ";
    	     }
    	     optionHtml+= " >"+item.showName+"</option>";
    	     selDom.append(optionHtml);
    	}
    }, function (data) {
        Feng.error("获取字典数据失败!" + data.responseJSON.message + "!");
    },true);
    ajax.setAsync(true);
    ajax.set(this.dictData);
    ajax.start();
};
Common.queryTVDictList = function (tableName,fieldName,docId,selectedCode) {
	this.dictData['tableName'] = tableName;
	this.dictData['fieldName'] = fieldName;
	//提交信息
    var ajax = new $ax(Feng.ctxPath + "/zlStatusDict/sonList", function (data) {
    	var selDom = $("#"+docId);
    	selDom.html(''); 
    	selDom.append("<option value=''>请选择</option>");
    	for (var i=0;i<data.length;i++) {
    		var item = data[i];
    	     var optionHtml = "<option value='"+item.value+"' ";
    	     if(item.value==selectedCode){
    	    	 optionHtml+= " selected='selected' ";
    	     }
    	     optionHtml+= " >"+item.showName+"</option>";
    	     selDom.append(optionHtml);
    	}
    }, function (data) {
        Feng.error("获取字典数据失败!" + data.responseJSON.message + "!");
    },true);
    ajax.setAsync(true);
    ajax.set(this.dictData);
    ajax.start();
};

Common.initEnumSelById = function (docId) {

	var packageName = $("#"+docId).attr("packageName");
//	 select.attr("id")
	this.dictData['packageName'] = packageName;
	//提交信息
//	var selectedCode = $("#"+docId).attr("selectedCode");
	var ajax = new $ax(Feng.ctxPath + "/dict/enumList", function (data) {
    	var selDom = $("#"+docId);
    	selDom.html(''); 
    	selDom.append("<option value=''>请选择</option>");
    	for (var i=0;i<data.length;i++) {
    		var item = data[i];
    	     var optionHtml = "<option value='"+item.value+"' ";
    	     if(item.value==selDom.attr("selectedCode")){
    	    	 optionHtml+= " selected='selected' ";
    	     }
    	     optionHtml+= " >"+item.showName+"</option>";
    	     selDom.append(optionHtml);
    	}
    }, function (data) {
        Feng.error("获取选项数据失败!" + data.responseJSON.message + "!");
    },true);
    ajax.setAsync(true);
    ajax.set(this.dictData);
    ajax.start();
   /* $.ajax({
        type: "GET",
        url: Feng.ctxPath + "/dict/enumList",
        data: this.dictData,
        dataType: "json",
        async: true,
        success: function(data){
	    	var selDom = $("#"+docId);
	    	selDom.html(''); 
	    	for (var i=0;i<data.length;i++) {
	    		var item = data[i];
	    	     var optionHtml = "<option value='"+item.value+"' ";
	    	     if(item.value==select){
	    	    	 optionHtml+= " selected='selected' ";
	    	     }
	    	     optionHtml+= " >"+item.showName+"</option>";
	    	     selDom.append(optionHtml);
	    	}
   
        }
    });*/
};


Common.initEnumRadioById = function (docId) {

	var packageName = $("#"+docId).attr("packageName");
	this.dictData['packageName'] = packageName;
	var ajax = new $ax(Feng.ctxPath + "/dict/enumList", function (data) {
    	var selDom = $("#"+docId);
    	selDom.html(''); 
    	for (var i=data.length-1;i>=0;i--) {
    		var item = data[i];
    	     var optionHtml = "<input value='"+item.value+"' ";
    	     if(item.value==selDom.attr("selectedCode")){
    	    	 optionHtml+= " checked='checked' ";
    	     }
    	     optionHtml+= " type='radio' ";
    	     optionHtml+= " name='"+docId+"' ";
    	     optionHtml+= " >"+item.showName+"</input>";
    	     selDom.after("&nbsp;&nbsp;&nbsp;&nbsp;");
    	     selDom.after(optionHtml);
    	}
    	$('input[type=radio][name='+docId+']').bind("click",function() {
    		var res=$(this).val();
            $("#"+docId).val(res);
        });
    }, function (data) {
        Feng.error("获取选项数据失败!" + data.responseJSON.message + "!");
    },true);
    ajax.setAsync(true);
    ajax.set(this.dictData);
    ajax.start();
};

Common.initRadioById = function (docId,json) {
	var selDom = $("#"+docId);
	selDom.html(''); 
	for (var i=json.data.length-1;i>=0;i--) {
		var item = json.data[i];
	     var optionHtml = "<input value='"+item.value+"' ";
	     if(item.value==selDom.attr("selectedCode")){
	    	 optionHtml+= " checked='checked' ";
	     }
	     optionHtml+= " type='radio' ";
	     optionHtml+= " name='"+docId+"' ";
	     optionHtml+= " >"+item.key+"</input>";
	     selDom.after("&nbsp;&nbsp;&nbsp;&nbsp;");
	     selDom.after(optionHtml);    
	}
	$('input[type=radio][name='+docId+']').bind("click",function() {
		var res=$(this).val();
        $("#"+docId).val(res);
    });
};

Common.queryTVDictListForRadio = function (tableName,fieldName,docId,selectedCode) {
	this.dictData['tableName'] = tableName;
	this.dictData['fieldName'] = fieldName;
	//提交信息
    var ajax = new $ax(Feng.ctxPath + "/zlStatusDict/sonList", function (data) {
    	var selDom = $("#"+docId);
    	for (var i=data.length-1;i>=0;i--) {
    		var item = data[i];
    		var optionHtml = "<input value='"+item.value+"' ";
	   	     if(item.value==selDom.attr("selectedCode")){
	   	    	 optionHtml+= " checked='checked' ";
	   	     }
	   	  optionHtml+= " type='radio' ";
	   	     optionHtml+= " type='radio' ";
	   	     optionHtml+= " name='"+docId+"' ";
	   	     optionHtml+= " >"+item.showName+"</input>";
	   	     selDom.after("&nbsp;&nbsp;&nbsp;&nbsp;");
	   	     selDom.after(optionHtml);
    	}
    	$('input[type=radio][name='+docId+']').bind("click",function() {
    		var res=$(this).val();
            $("#"+docId).val(res);
        });
    }, function (data) {
        Feng.error("获取字典数据失败!" + data.responseJSON.message + "!");
    },true);
    ajax.setAsync(true);
    ajax.set(this.dictData);
    ajax.start();
    
    
};

